lane :all do
  read_json_test
  download_json_test
  write_json_test
  merge_jsons_test
end

lane :read_json_test do
  my_json = read_json(
    json_path: "#{__dir__}/spec/resources/example.json",
    verbose: true
  )

  p(my_json)
end

lane :download_json_test do
  my_json = download_json(
    json_url: "https://gist.githubusercontent.com/MartinGonzalez/77b28af666fc2ee844c96cf6c8c221a2/raw/d23feabf25abe39c9c7243fd23f92efa7f50a3fd/someExample.json",
    verbose: true
  )

  p(my_json)
end

lane :write_json_test do
  hash = {
    name: "Martin",
    age: 30
  }

  file_path = "#{__dir__}/tmp/test.json"
  file_dir = File.dirname("../#{file_path}")

  write_json(
    hash: hash,
    file_path: file_path,
    verbose: true
  )

  p(File.read("../#{file_path}"))

  FileUtils.rm_rf(file_dir)
end

lane :merge_jsons_test do
  output_path = "#{__dir__}/tmp/merged.json"

  merged_hash = merge_jsons(
    jsons_paths: [
      "#{__dir__}/spec/resources/example.json",
      "#{__dir__}/spec/resources/example2.json"
    ],
    output_path: output_path,
    verbose: true
  )

  puts("Hash Value")
  puts(merged_hash)

  puts("Json file Value")
  puts(File.read("../#{output_path}"))
  FileUtils.rm_rf(File.dirname("../#{output_path}"))
end
